<template>
  <header class="header clearfix">
    <div class="title" :style="{ 'margin-left': isMobile ? '8px' : '22px' }">
      &nbsp;&nbsp;{{ title }}
    </div>
    <div class="list-left-container" v-if="areaList.length">
      <div class="guide-area">
        <select v-model="selectArea" @change="areaChange">
          <option
            :value="item.pid"
            v-for="(item, index) in areaList"
            :key="index"
            >{{ item.pname }}</option
          >
        </select>
      </div>
    </div>
    <div
      class="list-right-container"
      :style="{ right: isMobile ? '0' : '40px' }"
      v-if="contrastsList.length"
    >
      <select v-model="contrasts" @change="contrastsChange">
        <option
          :value="item.id"
          v-for="(item, index) in contrastsList"
          :key="index"
          >{{ item.label }}</option
        >
      </select>
    </div>
  </header>
</template>

<script>
import { isMobile } from '../utils/index'
export default {
  props: {
    title: {
      type: String,
      default: () => {
        return ''
      }
    },
    areaList: {
      type: Array,
      default: () => {
        return []
      }
    },
    contrastsList: {
      default: () => {
        return []
      }
    }
  },
  data () {
    return {
      selectArea: '0',
      contrasts: '0',
      isMobile: false
    }
  },

  methods: {
    contrastsChange () {
      this.$emit('contrastsChange', this.contrasts, this.title)
    },
    areaChange (changeOf) {
      this.$emit('areaChange', this.selectArea, this.title)
    }
  },

  mounted () {
    this.isMobile = isMobile()
  }
}
</script>

<style lang="scss" scoped>
.header {
  align-items: center;
  height: 40px;
  width: 100%;
  position: relative;
  color: #fff;
  .title {
    margin-left: 22px;
    height: 14px;
    line-height: 14px;
    padding-left: 10px;
    border-left: 4px solid #008bf3;
    font-weight: 700;
    font-size: 17px;
    color: #fff;
    margin-top: 22px;
  }
  .list-left-container {
    margin-left: 20px;
    .guide-area {
      display: flex;
      align-items: center;
      font-size: 14px;
      position: relative;
      .area {
        color: #898989;
      }
      .right-arrow {
        cursor: pointer;
        width: 24px;
        height: 24px;
        transform: rotate(-90deg);
        margin-left: 10px;
      }
      .area-list {
        padding: 8px !important;
        background: rgba(226, 227, 230, 0.8);
        width: 100px;
        position: absolute;
        left: 100%;
        top: 0;
        z-index: 201;
        .area-list-item {
          color: #999;
          line-height: 24px;
        }
      }
    }
  }
  .list-right-container {
    position: absolute;
    z-index: 200;
    top: 6px;
    .list {
      background: rgba(226, 227, 230, 0.5);
      float: left;
    }
    .item {
      display: flex;
      align-items: center;
      line-height: 24px;
      color: #999;
      padding: 0 10px !important;
      font-size: 12px;
      &:first-child {
        border-bottom: 1px solid #fff;
      }
    }
    .static-select-icon {
      cursor: pointer;
      float: left;
      width: 24px;
      height: 24px;
      display: flex;
      justify-content: center;
      align-items: center;
      background: rgba(226, 227, 230, 0.4);
      .arrow {
        width: 20px;
        height: 20px;
      }
    }
  }
}

.show-text {
  float: left;
  color: #9c9c9c;
  left: 0;
  width: 91px;
  height: 23px;
  background: #f3f4f5;
  line-height: 23px;
  text-align: center;
}
</style>
